{% extends 'base.html' %}
{% load pp_url %}
{% load issuetags %}
{% load solutiontags %}
{% load argumenttags %}

{% block title %}
Issue detail
{% endblock title %}
{% block content %}
    
{% pp_get_issue object=request.object %}
<h2>Details for {{pp_issue.issue.name|title}}</h2>   
    <ul>
    
        <li>{{pp_issue.issue.topic}}</li>
        <li>{{pp_issue.issue.name}}</li>
        <li>{{pp_issue.issue.pub_date}}</li>
        <li>{{pp_issue.issue.text }}</li>
        <li><a href="/upvote/{{pp_issue.issue.topic}}/{{pp_issue.issue.id}}">Support: {{ pp_issue.upvotes }}</a></li>
        <li><a href="/neutvote/{{pp_issue.issue.topic}}/{{pp_issue.issue.id}}">Neutral: {{ pp_issue.neutralvotes }}</a></li>
        <li><a href="/downvote/{{pp_issue.issue.topic}}/{{pp_issue.issue.id}}">Oppose: {{ pp_issue.neutralvotes }}</a></li>
    </ul>



    {% pp_get_solution_list issue=pp_issue.issue %}

<!--Get list of solutions and display them-->

        {% for solution in pp_solution.solution_list %}

             <span class="detailLink"><a href="{% pp_url template="solution.html" object=solution %}">Solution:</a></span>
            {{solution.name}} <br>
            {{solution.text}} <br> <br>
                
            {% pp_get_arg_types %}

<!--Display Arguments for this solution-->

               {% for arg_type in pp_argumentation.arg_type_list %}

                    {{arg_type}} <br>

                    {% pp_get_argument_list object=solution arg_type=arg_type %}

                        {% for arg in pp_argumentation.argument_list %}
                            {{arg.name}} <br>
                            {{arg.text}} <br>

                        {% endfor %}

                    {% endpp_get_argument_list %}

<!--Form for adding new arguments for this solution-->
                {% pp_argument_form POST=request.POST path=request.path user=request.user object=solution arg_type=arg_type %}

               <div id = "add">
               <hr />
               {{ pp_argumentation.form.errors }}
	            <form method="post" action="">
                    {{ pp_argumentation.form.as_p }}
		            {% csrf_token %}
                  <input type="submit" value="Submit">
	            </form>
	            </div>

                {% endpp_argument_form %}

            {% endfor %}

            {% endpp_get_arg_types %}

        {% endfor %}

    {% endpp_get_solution_list %}

<!--Begin Solution Form for adding new solutions-->
            <br>
            Add Solution: <br>
    {% pp_solution_form POST=request.POST path=request.path user=request.user issue=pp_issue.issue %}

               <div id = "add">
               <hr />
               {{ pp_solution.form.errors }}
	            <form method="post" action="">
                    {{ pp_solution.form.as_p }}
		            {% csrf_token %}
                  <input type="submit" value="Submit">
	            </form>
	            </div>

                {% endpp_solution_form %}



{% endpp_get_issue %}


{% endblock content %}




